{/* LAYOUT模板 */}
	<layout name="login_layout"/>
{/* LAYOUT模板 */}
{/* import Js,Css */}	
	<css href="__THEMES__/css/style.css" />
	<css href="__PUBLIC__/css/jquery-ui.css" />
	<js href="__PUBLIC__/js/core/jquery-1.8.0.js" />
	<js href="__PUBLIC__/js/jquery-ui.1.10.4.js" />
{/* import js,css */}

<style>
	.product_intro {background:url('__THEMES__/images/zqsy.jpg') top center no-repeat; height:500px; }
</style>


<div class="product_intro"> 

</div>



<script type="text/javascript">
	function $id(element) {
		return document.getElementById(element);
	}
	//切屏--是按钮，_v是内容平台，_h是内容库
	function reg(str){
		var bt			=	$id(str+"_b").getElementsByTagName("h2");
		for(var i=0;i<bt.length;i++){
			bt[i].subj	=	str;
			bt[i].pai	=	i;
			bt[i].style.cursor	=	"pointer";
			bt[i].onclick=function(){
				$id(this.subj+"_v").innerHTML	=	$id(this.subj+"_h").getElementsByTagName("blockquote")[this.pai].innerHTML;
				for(var j=0;j<$id(this.subj+"_b").getElementsByTagName("h2").length;j++){
					var _bt=$id(this.subj+"_b").getElementsByTagName("h2")[j];
					var ison	=	j	==	this.pai;
					_bt.className=(ison?"":"h2bg");
				}
			}
		}
		$id(str+"_h").className	=	"none";
		$id(str+"_v").innerHTML	=	$id(str+"_h").getElementsByTagName("blockquote")[0].innerHTML;
	}
	
	/* *
	 * 添加商品到购物车 
	 */
	function addToCart(goodsId, parentId){
		var goods        = new Object();
		var spec_arr     = new Array();
		var fittings_arr = new Array();
		var number       = 1;
		var formBuy      = document.forms['ECS_FORMBUY'];
		var quick		   = 0;

		// 检查是否有商品规格 
		if (formBuy){
				spec_arr = getSelectedAttributes(formBuy);

			if (formBuy.elements['number']){
			  number = formBuy.elements['number'].value;
			}

			quick = 1;
		}

		goods.quick    = quick;
		goods.spec     = spec_arr;
		goods.goods_id = goodsId;
		goods.number   = number;
		goods.parent   = (typeof(parentId) == "undefined") ? 0 : parseInt(parentId);
		
		//Ajax.call('flow.php?step=add_to_cart', 'goods=' + goods.tojsONString(), addToCartResponse, 'POST', 'jsON');
		$.ajax({
			url:'__URL__/add_to_cart',
			type:'post',
			dataType:'json',
			data:{goods:goods},
			beforeSend:function(){},
			success:function(msg){
				alert(msg);
			}
		});
	}
		
	/**
	 * 获得选定的商品属性
	 */
	function getSelectedAttributes(formBuy){
		var spec_arr = new Array();
		var j = 0;
		for (i = 0; i < formBuy.elements.length; i ++ ){
			var prefix = formBuy.elements[i].name.substr(0, 5);
			if (prefix == 'spec_' && (((formBuy.elements[i].type == 'radio' || formBuy.elements[i].type == 'checkbox') && formBuy.elements[i].checked) || formBuy.elements[i].tagName == 'SELECT')){
				spec_arr[j] = formBuy.elements[i].value;
				j++ ;
			}
		}
		return spec_arr;
	}
		
</script>


<div class="block clearfix "  style="width:960px; margin:auto;">
	<!--left start-->
	<div class="AreaL hide">
		<!--左边的购物车-->
			<!--<include file="Goods:cart"/>-->
		<!--左边的购物车-->
		<div class="blank5"></div>
		<!--商品分类-->
			<!--<include file="Goods:category_tree"/>-->
		<!--商品分类-->
		<div class="blank5"></div>
		<!--相关商品-->
			<!--<include file="Goods:goods_related"/>-->
		<!--相关商品-->
		<!--相关配件-->
			<!---<include file="Goods:goods_fittings"/>-->
		<!--相关配件-->
		<!--相关文章-->
			<!--<include file="Goods:goods_article"/>-->
		<!--相关文章-->
		<div class="blank5"></div>
		<!--属性关联的商品-->
			<!---<include file="Goods:goods_attrlinked"/>-->
		<!--属性关联的商品-->
		<!--历史记录-->
			<!--<include file="Goods:history"/>-->
		<!--历史记录-->
	</div>	
	<!--left end-->
	<!--right start-->
	<div class="AreaR">
		<!--商品详情start-->
		<div id="goodsInfo" class="clearfix">
			<!--商品图片和相册 start-->
				<div class="imgInfo">
					<if condition="$pictures">
						<a href="javascript:;" onclick="window.open('gallery.php?id={$goods.goods_id}'); return false;">
						<img src="__PUBLIC__/Upload/{$goods.goods_img}" alt="{$goods.goods_name}"/>
						</a>
					<else/>
						<img src="__PUBLIC__/Upload/{$goods.goods_img}" alt="{$goods.goods_name}"/>
					</if>
					<div class="blank5"></div>
					<!--相册 START-->
					<include file="Goods:goods_gallery"/>
					<!--相册 END-->
					<div class="blank5"></div>
				</div>
			<!--商品图片和相册 end-->
				<div class="textInfo">
					<form action="javascript:addToCart({$goods.goods_id})" method="post" name="ECS_FORMBUY" id="ECS_FORMBUY" >
						<div class="clearfix">
							<p class="f_l">{$goods.goods_style_name}</p>
							<p class="f_r">
								<if condition="$prev_good">
									<a href="{$prev_good.url}"><img alt="prev" src="./images/up.gif" /></a>
								</if>
								<if condition="$next_good">
									<a href="{$next_good.url}"><img alt="next" src="./images/down.gif" /></a>
								</if>
							</p>
						</div>
						<ul>
						<if condition="$promotion">
							<li class="padd">
								<volist name="promotion" id="item">
									{$lang.activity}									
									<a href="{$item.url}" title="{$lang.$item.type} {$item.act_name}{$item.time}" style="font-weight:100; color:#006bcd;">{$item.act_name}</a><br />
								</volist>
							</li>
						</if>
						<li class="clearfix">
							<dd>
								<if condition="$cfg['show_goodssn']">
									<strong>{$lang.goods_sn}</strong>{$goods.goods_sn}
								</if>
							</dd>
							<dd class="ddR">
								<if condition="$goods['goods_number'] neq '' and $cfg['show_goodsnumber']">
									<if condition="$goods['goods_number'] eq 0">
										<strong>{$lang.goods_number}</strong>
										<font color='red'>{$lang.stock_up}</font>
									<else/>
										<strong>{$lang.goods_number}</strong>
										{$goods.goods_number} {$goods.measure_unit}
									</if>
								</if>
							</dd>
						</li>
						<li class="clearfix">
							<dd>
								<if condition="$goods['goods_brand'] neq '' and $cfg['show_brand']">
									<strong>{$lang.goods_brand}</strong>
									<a href="{$goods.goods_brand_url}" >{$goods.goods_brand}</a>
								</if>
							</dd>
							<dd class="ddR">							
								<if condition="$cfg['show_goodsweight']">
									<strong>{$lang.goods_weight}</strong>{$goods.goods_weight}
								</if>
							</dd>
						</li>
						<li class="clearfix">
							<dd>
								<if condition="$cfg['show_addtime']">
									<strong>{$lang.add_time}</strong>{$goods.add_time}
								</if>
							</dd>
							<dd class="ddR">
								<!--点击数-->
								<strong>{$lang.goods_click_count}：</strong>{$goods.click_count}
							</dd>
						</li>
						<li class="clearfix">
							<dd class="ddL">
								<if condition="$cfg['show_marketprice']">
									<strong>{$lang.market_price}</strong><font class="market">{$goods.market_price}</font>
									<br/>
								</if>
								<!--本店售价-->
								<strong>{$lang.shop_price}</strong>
								<font class="shop" id="ECS_SHOPPRICE">{$goods.shop_price_formated}</font>
								<br/>
							</dd>
							<dd style="width:48%; padding-left:7px;">
								<strong>{$lang.goods_rank}</strong>
								<img src="__THEMES__/images/stars{$goods.comment_rank}.gif" alt="comment rank {$goods.comment_rank}" />
							</dd>
						</li>

						<if condition="$goods['is_promote'] and $goods['gmt_end_time']">
							<li class="padd loop" style="margin-bottom:5px; border-bottom:1px dashed #ccc;">
								<strong>{$lang.promote_price}</strong>
								<font class="shop">{$goods.promote_price}</font><br/>
								<strong>{$lang.residual_time}</strong>
								<font class="f4" id="leftTime">{$lang.please_waiting}</font><br/>
							</li>
						</if>
						<li class="clearfix">
							<dd>
								<strong>{$lang.amount}：</strong>
								<font id="ECS_GOODS_AMOUNT" class="shop"></font>
							</dd>
							<dd class="ddR">
								<if condition="$goods['give_integral'] gt 0">
									<strong>{$lang.goods_give_integral}</strong><font class="f4">{$goods.give_integral} {$points_name}</font>
								</if>
							</dd>
						</li>
						<if condition="$goods['bonus_money']">
							<li class="padd loop" style="margin-bottom:5px; border-bottom:1px dashed #ccc;">
								<strong>{$lang.goods_bonus}</strong><font class="shop">{$goods.bonus_money}</font><br />
							</li>
						</if>
						<li class="clearfix">
							<dd>
								<strong>{$lang.number}：</strong>
								<input name="number" type="text" id="number" value="1" size="4" onblur="changePrice()" style="border:1px solid #ccc; "/>
							</dd>
							<dd class="ddR">								
								<if condition="$cfg['use_integral']">
									<strong>{$lang.goods_integral}</strong><font class="f4">{$goods.integral} {$points_name}</font>
								</if>
							</dd>
						</li>
						<if condition="$goods['is_shipping']">
							<li style="height:30px;padding-top:4px;">
								{$lang.goods_free_shipping}<br />
							</li>
						</if>
						
						<!-- {* 开始循环所有可选属性 *} -->
						<volist name="specification" id="spec" key="spec_key">
							<li class="padd loop">
								<strong>{$spec.name}:</strong><br />
								<!-- {* 判断属性是复选还是单选 *} -->
								<if condition="$spec['attr_type'] eq 1">
									<if condition="$cfg['goodsattr_style'] eq 1">
										<volist name="spec['values']" id="value" key="key">
											<label for="spec_value_{$value.id}">
												<input type="radio" name="spec_{$spec_key}" value="{$value.id}" id="spec_value_{$value.id}" <if condition="$key eq 0">checked</if> onclick="changePrice()" />
												{$value.label} 
												[<if condition="$value['price'] gt 0">{$lang.plus}<elseif condition="$value['price'] lt 0"/>{$lang.minus}</if> {$value.format_price}] 
											</label>
											<br/>
										</volist>
										<input type="hidden" name="spec_list" value="{$key}" />
									<else/>								
										<select name="spec_{$spec_key}" onchange="changePrice()">
											<volist name="$spec['values']" id="value" key="key">
												<option label="{$value.label}" value="{$value.id}">
													{$value.label} 
													<if condition="$value['price'] gt 0">
														{$lang.plus}
													<elseif condition="$value['price'] lt 0"/>
														{$lang.minus}
													</if>
													<if condition="$value['price'] neq 0">
														{$value.format_price}
													</if>
												</option>
											</volist>
										</select>
										<input type="hidden" name="spec_list" value="{$key}" />
									</if>
								<else/>
									<volist name="$spec['values']" id="value" key="key">
										<label for="spec_value_{$value.id}">
											<input type="checkbox" name="spec_{$spec_key}" value="{$value.id}" id="spec_value_{$value.id}" onclick="changePrice()" />
											{$value.label} 
											[<if condition="$value['price'] gt 0">
												{$lang.plus}
											<elseif condition="$value['price'] lt 0"/>
												{$lang.minus}
											</if>
											{$value.format_price}] 
										</label>
										<br/>
									</volist>
									<input type="hidden" name="spec_list" value="{$key}" />
								</if>
							</li>
						</volist>
						<li class="padd">
							<a href="javascript:addToCart({$goods.goods_id})"><img src="__THEMES__/images/bnt_cat.gif" /></a>
							<a href="javascript:collect({$goods.goods_id})"><img src="__THEMES__/images/bnt_colles.gif" /></a>
							<if condition="$affiliate['on']">
								<a href="user.php?act=affiliate&goodsid={$goods.goods_id}"><img src="__THEMES__/images/bnt_recommend.gif'></a>
							</if>
						</li>
					</ul>
				</form>
			</div>
		</div>
		<div class="blank"></div>
	<!--商品详情end-->
	
</div>
<!--right end-->
</div>

<script type="text/javascript">
	var goods_id = {$goods_id};
	var goodsattr_style = {$cfg.goodsattr_style};
	//var gmt_end_time = {$promote_end_time};
	var goodsId = {$goods_id};
	//var now_time = {$now_time};

	onload = function(){
		changePrice();
		//fixpng();
		try { onload_leftTime(); }
		catch (e) {}
	}

	/**
	 * 点选可选属性或改变数量时修改商品价格的函数
	 */
	function changePrice(){
		var attr 	= 	getSelectedAttributes(document.forms['ECS_FORMBUY']);
		var qty 	= 	document.forms['ECS_FORMBUY'].elements['number'].value;
		//Ajax.call('goods.php', 'act=price&id=' + goodsId + '&attr=' + attr + '&number=' + qty, changePriceResponse, 'GET', 'jsON');
		$.ajax({
			url:'__URL__/change_price?' + 'act=price&id=' + goodsId + '&attr=' + attr + '&number=' + qty,
			type:'get',
			dataType:'json',
			data:{},
			beforeSend:function(){},
			success:function(msg){
				changePriceResponse(msg);
			}
		});
	}

	/**
	 * 接收返回的信息
	 */
	function changePriceResponse(res){
		if (res.err_msg.length > 0){
			alert(res.err_msg);
		}
		else{
			document.forms['ECS_FORMBUY'].elements['number'].value = res.qty;
			if (document.getElementById('ECS_GOODS_AMOUNT'))
			document.getElementById('ECS_GOODS_AMOUNT').innerHTML = res.result;
		}
	}
	
</script>





